
$(function () {  
// 1.获取url地址栏，控制菜单栏的展开和隐藏
let pathname = location.pathname;
   if( pathname.indexOf('/admin/posts') != -1
   || pathname.indexOf('/admin/post-add') != -1
   || pathname.indexOf('/admin/categories') != -1
   ){
    //  一级菜单改为true
    $('#posts-top').attr('aria-expanded',true).removeClass('collapsed');
  //   // 二级改为show
    $('#menu-posts').addClass('show');
   };
   if( pathname.indexOf('/admin/slides') != -1
   || pathname.indexOf('/admin/settings') != -1){
     $('#menu-settings-top').attr('aria-expanded',true);
     $('#menu-settings').addClass('show');
   }
  // 设置对应的li高亮
  // let index = pathname.indexOf('/admin') + 7;
  let currentId = pathname.substring(7);
  currentId = currentId || 'index'
  $('#'+currentId).addClass('active');

//  获取昵称和头橡
// $.get('/getNicknameImage',(res)=>{
//   // console.log(res);
//   if(res.code == 200){
//     $('.profile .avatar').attr('src',res.data.avatar);
//     $('.profile .name').text(res.data.nickname);
//   };
// });

});